home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / miscuni.com / TPCLOCK.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1989-05-25  |  2.8 KB  |  96 lines

  1. (*****************************************************************)
  2. (*                           Unit TPClock                        *)
  3. (*                                                               *)
  4. (*  Author: Geoffrey Moehrke                                     *)
  5. (*  Date:   May 16, 1989                                         *)
  6. (*                                                               *)
  7. (*  Purpose: Allow display of on screen clock - unit sits on top *)
  8. (*           of TPCRT and provides replacement for kbd routines  *)
  9. (*           as well as exporting the procedure that displays    *)
  10. (*           the date and time on screen.                        *)
  11. (*                                                               *)
  12. (*  Source: F:\TP\UNIT\TPCLOCK                                   *)
  13. (*****************************************************************)
  14. Unit TPClock;
  15.  
  16.   Interface
  17.  
  18.     const
  19.       CalendarEnabled : boolean = False;  { Display the date }
  20.       ClockEnabled : Boolean = False;     { Display the time }
  21.  
  22.       ClockTimeMask : String[20] = 'HH:mm:ss te'; { Mask for time }
  23.       ClockDateMask : String[20] = 'MM/dd/yy';    { Mask for date }
  24.       ClockSepStr   : String[20] = '  '; { string displays between time & date }
  25.  
  26.       ClockX : byte = 59;   { Base coordinates for time/date display }
  27.       ClockY : byte = 1;
  28.  
  29.     Var
  30.       ClockAttr : Byte;     { Attribute for clock display            }
  31.  
  32.     procedure ShowClock;
  33.       { Show clock on screen }
  34.  
  35.    { Replacements for TPCRT routines - each calls <ShowClock> then
  36.      the corresponding routine from TPCRT.                          }
  37.  
  38.     Function KeyPressed : boolean;
  39.     Function ReadKeyWord : Word;
  40.     Function CheckKbd(var KeyCode : Word) : boolean;
  41.     Function ReadKey : char;
  42.  
  43.  Implementation
  44.  
  45.    Uses
  46.      TPDate,
  47.      TPCRT;
  48.  
  49.   procedure ShowClock;
  50.  
  51.   begin
  52.     if CalendarEnabled then
  53.       FastWrite( TodayString(ClockDateMask),
  54.                  ClockY, ClockX, ClockAttr );
  55.     if ClockEnabled then
  56.       FastWrite( ClockSepStr + CurrentTimeString( ClockTimeMask ),
  57.                  ClockY, ClockX+Length(ClockDateMask), ClockAttr);
  58.   end;
  59.  
  60.  
  61.   Function Keypressed : boolean;
  62.  
  63.     begin
  64.       ShowClock;
  65.       KeyPressed := TPCRT.KeyPressed;
  66.     end;
  67.  
  68.   Function ReadKeyWord : Word;
  69.  
  70.     begin
  71.         repeat
  72.           { do nothing }
  73.         until Keypressed;
  74.       ReadKeyWord := TPCRT.ReadKeyWord;
  75.     end;
  76.  
  77.   Function CheckKbd( Var KeyCode : Word ): Boolean;
  78.  
  79.     begin
  80.       ShowClock;
  81.       CheckKbd := TPCRT.CheckKbd( KeyCode );
  82.     end;
  83.  
  84.   function ReadKey : char;
  85.  
  86.     begin
  87.       repeat
  88.         { do nothing }
  89.       until Keypressed;
  90.       ReadKey := TPCRT.ReadKey;
  91.     end;
  92.  
  93.  
  94. begin
  95.   ClockAttr := TextAttr;
  96. end.